package maze;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import maze.ui.MazeViewer;

public class launchMaze {

	public static void main(String[] args) {
		MazeFactory mazeFactory = new MazeFactory();
		String mazePath = ".\\large.maze";
		
		File mazeTypeFile = new File("type.maze");
		BufferedReader mazeTypeBuff = null;
		try {
			mazeTypeBuff = new BufferedReader(new FileReader(mazeTypeFile));
			String mazeType = mazeTypeBuff.readLine();
			mazePath = mazeType.substring(9);
			
			mazeType = mazeTypeBuff.readLine();
			//System.out.println(mazeType);
			if(mazeType.equals("A Blue Maze Game")) {
				mazeFactory = new BlueMazeFactory();
			}
			else if(mazeType.equals("A Red Maze Game")) {
				mazeFactory = new RedMazeFactory();
			}
		}catch(Exception e){
			e.printStackTrace();
		}finally {
			try {
				mazeTypeBuff.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		MazeGameCreator mazeGame = new MazeGameCreator(mazeFactory);
		
		//Maze maze = createLargeMaze();
		Maze maze = mazeGame.loadMaze(mazePath);
	    MazeViewer viewer = new MazeViewer(maze);
	    viewer.run();
	}

}
